package com.lagou.mr.sorttest;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * mapper 方法，
 * LongWritable, Text：偏移量，  Text:每一行文本内容
 * SortBean, NullWritable    SortBean：输出key， 输出value
 */
public class SortMapper extends Mapper<LongWritable, Text,SortBean, NullWritable> {


    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String str = value.toString().trim();
        SortBean bean = new SortBean();
        bean.setIndex(0);
        bean.setNum(Integer.parseInt(str));
        //返回bean
        context.write(bean,NullWritable.get());

    }
}
